FROM debian:13.1-slim
ADD ruby-3.4.7.tar.gz /usr/local/
WORKDIR /usr/local/ruby-3.4.7
RUN sed -i s/deb.debian.org/mirrors.ustc.edu.cn/g /etc/apt/sources.list.d/debian.sources  && \
apt-get -y update && apt-get upgrade -y && apt-get -y install gcc make libyaml-dev libssl-dev ca-certificates zlib1g-dev && \
./configure && make -j8 && make install && \
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ && \
apt-get remove gcc make -y && apt-get autoremove -y  && \
rm -rf /usr/local/ruby-3.4.7 && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/local
CMD ["ruby","-v"]

# https://rubygems.org/
# https://mirrors.aliyun.com/rubygems/
# docker build -t registry.cn-hangzhou.aliyuncs.com/xiaoyilin/ruby:3.4.7 .
# docker run --rm registry.cn-hangzhou.aliyuncs.com/xiaoyilin/ruby:3.4.7
# docker run -it --rm registry.cn-hangzhou.aliyuncs.com/xiaoyilin/ruby:3.4.7 bash
# docker push registry.cn-hangzhou.aliyuncs.com/xiaoyilin/ruby:3.4.7
# 默认Ruby安装目录/usr/local
# 如果想使用其他目录--prefix=DIR 选项传给./configure 脚本

#无法使用任何工具来管理通过源码编译安装的 Ruby，所以使用第三方工具或者包管理器或许是更好的选择。
# https://www.debian.org/mirror/list